package cn.jroid.demo;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;
import android.widget.TextView;
import cn.jroid.demo.adapter.UserListAdapter;
import cn.jroid.demo.entity.User;
import cn.jroid.demo.entity.UserList;
import cn.jroid.ui.BaseActivity;

public class JsonTestActivity extends BaseActivity {
	
	private TextView textView;
	
	private ListView listView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		textView = (TextView) findViewById(R.id.show);
		listView = (ListView) findViewById(R.id.list);
		/*
		String jsonContent = "{\"username\":\"\u8bb8\u5b5d\u6781\",\"content\":\"\u8fd9\u662fContent\u90e8\u5206\"}";
		User user = parseFromString(jsonContent);
		*/
		String jsonContent = "[{\"username\":\"\u54c8\u54c8\u54c8\u54c8\",\"content\":\"\u6d4b\u8bd5\u5185\u5bb9\u4e00\"},{\"username\":\"\u54c8\u54c8\u54c8\u54c8\",\"content\":\"\u6d4b\u8bd5\u5185\u5bb9\u4e00\"},{\"username\":\"\u54c8\u54c8\u54c8\u54c8\",\"content\":\"\u6d4b\u8bd5\u5185\u5bb9\u4e00\"},{\"username\":\"\u54c8\u54c8\u54c8\u54c8\",\"content\":\"\u6d4b\u8bd5\u5185\u5bb9\u4e00\"},{\"username\":\"\u54c8\u54c8\u54c8\u54c8\",\"content\":\"\u6d4b\u8bd5\u5185\u5bb9\u4e00\"}]";
		UserList userList = UserList.parse(jsonContent);
		textView.setText(userList.toString());
		
		UserListAdapter adapter = new UserListAdapter(this, userList);
		listView.setAdapter(adapter);
	}
	
	
}
